home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Sample Code / AppsToGo / DTS.Lib / DTS.Lib.headers / GWLayers.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-09-22  |  28.2 KB  |  624 lines  |  [TEXT/MPS ]

  1. #ifndef __GWLAYERS__
  2. #define __GWLAYERS__
  3.  
  4. #ifndef __TYPES__
  5. #include "Types.h"
  6. #endif
  7.  
  8. #ifndef __MEMORY__
  9. #include <Memory.h>
  10. #endif
  11.  
  12. #ifndef __QDOFFSCREEN__
  13. #include <QDOffscreen.h>
  14. #endif
  15.  
  16. #ifndef __QUICKDRAW__
  17. #include <Quickdraw.h>
  18. #endif
  19.  
  20. struct LayerRec;
  21. typedef struct LayerRec *LayerRecPtr, **LayerObj;
  22.  
  23. typedef OSErr (*LayerProc)(LayerObj theLayer, short message);
  24.  
  25. typedef struct LayerRec {
  26.     LayerObj        aboveLayer;
  27.     LayerObj        belowLayer;
  28.     Boolean         layerOwnsPort;
  29.     GrafPtr            layerPort;
  30.     GDHandle        layerGDevice;
  31.     Handle            layerBitmap;
  32.     short            layerDepth;
  33.     LayerProc        layerProc;
  34.     unsigned long    layerData;
  35.     short            xferMode;
  36.     Rect            srcRect;
  37.     Rect            dstRect;
  38.     Rect            thisUpdate;
  39.     Rect            lastUpdate;
  40.     Boolean            includeLastUpdate;
  41.     Boolean            lockedCount;
  42.     Boolean            cachedCount;
  43.     CGrafPtr        cachedPort;
  44.     GDHandle        cachedGDevice;
  45. } LayerRec;
  46.  
  47. #define kLayerInit    0
  48. #define kLayerDispose 1
  49. #define kLayerUpdate  2
  50.  
  51.  
  52.  
  53. #ifdef __cplusplus
  54. extern "C" {
  55. #endif
  56.  
  57.  
  58.  
  59. OSErr    NewLayer(LayerObj *newLayer, LayerObj aboveLayer, LayerProc theProc,
  60.                  GrafPtr basePort, short depth, unsigned long theData);
  61.     /*
  62.     **    ¶ Create a layer object for offscreen drawing.
  63.     **
  64.     **    INPUT:    aboveLayer        This is the layer above the layer to create.
  65.     **                            If the layer is to be the top layer, then pass nil here.
  66.     **            theProc            The procedure pointer for the layer object.  If the default
  67.     **                            actions are all okay, then pass in nil here.
  68.     **            basePort        If you pass in a port here, then NewLayer won’t create one
  69.     **                            for you.  If no port is passed in, then it will create an
  70.     **                            offscreen GWorld (or port for system 6), based on the size/depth
  71.     **                            of the layer above (and some other factors).
  72.     **            depth            The depth to create the offscreen.  If 0 is passed in, then
  73.     **                            the depth is based on the above port.
  74.     **            theData            Application reference field.  Store whatever you want here.
  75.     **    OUTPUT:    newLayer        If successful, a LayerObj handle will be returned here.
  76.     **                            If unsuccessful, a nil will be returned here.
  77.     **    RESULT:    OSErr            The most likely error is memFullErr.
  78.     **
  79.     **    GWLayers is meant to simplify and standardize offscreen drawing in a flexible way.
  80.     **
  81.     **    NOTE:    This package was originally written for use with GWorlds, but system 6
  82.     **            support has been added.  You no longer need system 7 or color quickdraw
  83.     **            to use this package.
  84.     **
  85.     **    Using offscreen GWorlds allows applications to achieve very clean graphics
  86.     **    effects that are not possible if drawing directly to a window (or grafPort).
  87.     **    In most cases, when an image is generated in an offscreen GWorld, that image
  88.     **    will end up being displayed in a window.
  89.     **
  90.     **    This relationship between offscreen GWorlds and windows needs to be managed.
  91.     **    In addition to one GWorld relating to a window, you may actually need multiple
  92.     **    GWorlds to relate to a window.  Many effects demand more than one offscreen
  93.     **    GWorld.  Smoothly dragging an image over a background is one such effect.
  94.     **
  95.     **    GWLayers.c is a block of code that manages the more mundane aspects of handling one
  96.     **    or more GWorlds.  GWLayers.c gives you a consistent way of relating GWorlds/windows
  97.     **    together.
  98.     **
  99.     **    A common use for offscreen GWorlds is to move an object around in a window smoothly
  100.     **    over a background.  To accomplish this, we need 3 layers.
  101.     **    These are:
  102.     **
  103.     **    1)    The window layer.  This is the top-most layer in the layer hierarchy.  The
  104.     **        top-most layer is typically what the user will see, and therefore commonly
  105.     **        is a window layer.  Layers below the top-most are typically offscreen
  106.     **        GWorlds.
  107.     **    2)    A middle layer that is used to apply the object being moved to the
  108.     **        background plus removing the object from the old location.  Once these
  109.     **        two tasks are done, the offscreen work area is ready to be transferred
  110.     **        to the window layer.
  111.     **    3)    A background image against which the object moves.  This is used to
  112.     **        restore the middle layer at the location where the object being moved
  113.     **        was last at.
  114.     **
  115.     **    The background layer is generated only once.  The relevant (changing) portions of
  116.     **    the background image are copied into the middle layer.  Once the background portion
  117.     **    is copied into the middle layer, the object that is moving across the background is
  118.     **    drawn into the middle layer on top of the background portion.
  119.     **
  120.     **    Once the middle layer has the background portion with the moving object drawn onto it,
  121.     **    the portion is transferred to the top-most layer, which is the window layer.  The user
  122.     **    sees only this final transfer, so the intermediate steps are completely hidden.  The
  123.     **    user just sees the object being dragged drawn into its new location.
  124.     **
  125.     **    To make the dragged object seem to move, it is also important to erase it from its
  126.     **    old location.  If this were done in two steps (restore old location, draw in new location),
  127.     **    the movement would flicker.  The user would be able to perceive (very easily) that
  128.     **    the object is first removed from the old location and the redrawn in the new location.
  129.     **    To prevent this flickering, the old location and the new location have to be updated
  130.     **    in a single step.  Working offscreen allows this.  The middle layer is first updated so
  131.     **    that the old location of the object is restored to background.  The middle layer then has
  132.     **    the object drawn into the new location.  And then when the transfer finally occurs into
  133.     **    the window layer, an area large enough to cover both the old location and the new location
  134.     **    are transferred at once with a single CopyBits.
  135.     **
  136.     **
  137.     **    GWLayers.c conventions:
  138.     **
  139.     **    Updating of each layer is handled by the layer itself.  A particular layer checks to
  140.     **    see if there is a layer below, and if there is, does a CopyBits of the relevant area
  141.     **    from the below layer into itself.  If after the CopyBits there is any additional
  142.     **    drawing needed (such as the middle layer in the above example), then it is typically
  143.     **    done after the CopyBits.
  144.     **
  145.     **    Since the layers actually need to update from the bottom-most layer to the top-most
  146.     **    layer (top-most being the window, showing the final result), the layer updating code
  147.     **    checks to see if there is a layer below.  If there is, then the update procedure is
  148.     **    called for the layer below.  This recursion continues until the bottom-most layer is
  149.     **    reached.  The bottom-most layer then does its thing.  (For the case where the bottom-most
  150.     **    layer is background this "thing" will be to do nothing.)  Once the update for the layer
  151.     **    is completed, the update procedure simply returns.  It will return to the caller, which
  152.     **    is the layer above it (if any).  The next layer up does its thing, and then returns, and
  153.     **    so on.  This recursive chain of layers allows the updating to happen automatically in
  154.     **    the order designated by the layer hierarchy.
  155.     **
  156.     **    Since window records and GWorld records don't have any fields for all of the stuff we
  157.     **    need to keep (such as above-layer, below-layer, update procedures, etc.), this
  158.     **    implementation uses a handle to hold the layer record.  Each layer record has a reference
  159.     **    to the window or GWorld is is to draw into, plus a reference to what layers records
  160.     **    are above and below, if any.  The structure for a layer record is as follows:
  161.     **
  162.     **    typedef struct LayerRec {
  163.     **        LayerObj        aboveLayer;            Nil if no above layer.
  164.     **        LayerObj        belowLayer;            Nil if no below layer.
  165.     **        Boolean         layerOwnsPort;        True if layer created the GWorld.
  166.     **        GrafPtr            layerPort;            Window or GWorld this layer draws into.
  167.     **        GDHandle        layerGDevice;        The GDevice for this layer.
  168.     **        Handle            layerBitmap;        If GWorlds aren't available, this holds the bitmap.
  169.     **        short            layerDepth;            Requested NewLayer depth of pixmap.
  170.     **        LayerProc        layerProc;            Layer procedure.  If nil, then default behaviors used.
  171.     **        unsigned long    layerData;            Application refCon-type field.
  172.     **        short            xferMode;            Transfer mode for CopyBits.
  173.     **        Rect            srcRect;            Initially nil, which makes entire GWorld source.
  174.     **        Rect            dstRect;            Initially nil, which makes entire window/GWorld dest.
  175.     **        Rect            thisUpdate;            Area to be updated for this update.
  176.     **        Rect            lastUpdate;            Area updated last time UpdateLayer was called.
  177.     **        Boolean            includeLastUpdate;    True is last updated area is o updated as well.
  178.     **        Boolean            lockedCount;        Used internally by GWorld locking/unlocking calls.
  179.     **        Boolean            cachedCount;        Used internally by GWorld locking/unlocking calls.
  180.     **        CGrafPtr        cachedPort;            Used internally by GWorld usage calls.
  181.     **        GDHandle        cachedGDevice;        Used internally by GWorld usage calls.
  182.     **    } LayerRec;
  183.     **
  184.     **    layerOwnsPort:
  185.     **        If the layer created the GWorld, then it is the layer's responsibility to get rid
  186.     **        of its GWorld when the layer is disposed of.  If this flag is true, the GWorld
  187.     **        will be disposed of when the layer is disposed of.
  188.     **
  189.     **    layerProc:
  190.     **        This is nil if the default behaviors are acceptable for a particular layer.
  191.     **        If this is non-nil, then you are responsible for implementing each layer
  192.     **        message behavior.  (More on this later.)
  193.     **
  194.     **    xferMode:
  195.     **        This is the transfer mode for CopyBits.  The default behavior for updating simply
  196.     **        transfers some or all of the below layer (if there is one) into the current layer.
  197.     **        It does this with CopyBits, using the designated transfer mode.
  198.     **
  199.     **    srcRect:
  200.     **        This is initially an empty rect.  If this srcRect is empty, then the portRect of the
  201.     **        GWorld is used as the srcRect.  This means the default srcRect is the entire GWorld.
  202.     **        If this field is set to a non-empty rect, the default update behavior is to do a CopyBits
  203.     **        of just the srcRect area, and not the entire GWorld.  (Remember, the CopyBits is done by
  204.     **        the above layer, so only if the above layer uses the default update behavior does this
  205.     **        occur automatically.)
  206.     **        Having a srcRect smaller than the entire GWorld allows for additional effects, such as
  207.     **        fat-bits.  If the srcRect for this layer is smaller than the dstRect of the above layer,
  208.     **        CopyBits will transfer a small rect into a big rect.  The image will be scaled to
  209.     **        accommodate the larger destination rect, and presto -- fat-bits!!
  210.     **
  211.     **    dstRect:
  212.     **        This field is initially an empty rect, just like srcRect.  If dstRect is set to a
  213.     **        non-empty rect, then the default update behavior will CopyBits only into this area.
  214.     **        This allows targeting of a specific portion of a window for offscreen updating, while
  215.     **        the rest of the window can be used from scrollbars, or some such other thing.
  216.     **
  217.     **    thisRect:
  218.     **        This field is also initially an empty rect.  This field becomes non-empty by
  219.     **        calling InvalLayer.  InvalLayer unions the rect passed to it into thisRect and
  220.     **        stores the result in thisRect.  It then calls itself if there is a below layer, thus
  221.     **        recursively changing thisRect for all layers below it in the layer hierarchy.
  222.     **
  223.     **    lastRect:
  224.     **        This field is also initially an empty rect.  This field becomes non-empty after
  225.     **        thisRect is non-empty and then UpdateLayer is called.  Once the update is done,
  226.     **        thisRect is copied into lastRect, and then thisRect is set empty once again.
  227.     **        The lastRect field is use to optionally combine updating the last update with the
  228.     **        current update.  This is particularly useful for dragging objects, as described above.
  229.     **        In a single CopyBits, the old location and the new location need to be drawn in the
  230.     **        window.  By setting includeLastUpdate true, this is done automatically by the default
  231.     **        update behavior.
  232.     **
  233.     **    includeLastUpdate:
  234.     **        As just described for the lastRect field, if this field is true, then the default
  235.     **        update behavior CopyBits includes both the last update and this update, thus generating
  236.     **        smooth animation effects.
  237.     **
  238.     **
  239.     **    A call to create a layer for a window (the top-most layer, most likely) might look like this:
  240.     **
  241.     **        NewLayer(&windowLayer,    Layer object handle is returned here.
  242.     **                  nil,            Top layer, so there is no above layer.
  243.     **                  nil,            Uses default layer procedure.
  244.     **                  window,         Window used by the layer object.
  245.     **                  0,              Depth for offscreen 0 for screen depth).
  246.     **                  0);             Custom layer init data, if any.
  247.     **
  248.     **    If NewLayer succeeds, the layer object handle is returned in windowLayer.  If it fails,
  249.     **    nil is returned in windowLayer, plus an error is returned.  This call can hardly fail, as
  250.     **    there is no offscreen GWorld created.  If only a minimally-sized handle can be created, it
  251.     **    will succeed.
  252.     **
  253.     **    To create a work layer below this window layer, we might make a call such as:
  254.     **
  255.     **        err = NewLayer(&workLayer, windowLayer, WorkLayerProc, nil, 0, (long)&myInfo);
  256.     **                myInfo is a struct that holds information that WorkLayerProc
  257.     **                needs to reference for drawing the object in the new location.
  258.     **
  259.     **    This call has a greater chance of failure, as an offscreen GWorld was created for it.
  260.     **    We passed it a nil grafPort, so the default initialization behavior knows that it will
  261.     **    have to create a GWorld.  The default initialization behavior uses dstRect of the above
  262.     **    layer as the size of the offscreen GWorld it is to create.  If dstRect is an empty rect,
  263.     **    then it uses the portRect of the above layer instead.  So if you wanted to map the offscreen
  264.     **    layer to just a portion of the window, you would set the dstRect for the top-most layer
  265.     **    prior to creating the middle layer.
  266.     **
  267.     **    IMPORTANT:  The default behavior automatically creates the offscreen GWorld to the described
  268.     **                size.  We have passed NewLayer a layer procedure, so we don't automatically get
  269.     **                the default behaviors for the middle layer.  This must be kept in mind when
  270.     **                writing the layer procedure for the middle layer.  To get the default behavior,
  271.     **                we simply call DefaultLayerInit when the layer procedure gets an initialization
  272.     **                message.  Since the default initialization behavior is exactly what we want, we
  273.     **                just call it directly.
  274.     **
  275.     **    The reason that we have a layer procedure for this layer is that we want to do something
  276.     **    different when we receive an update message.  For the update message we want to first
  277.     **    transfer the portion of background into the middle layer, and then we want to draw the object
  278.     **    we are dragging into the middle layer.  For the update message, we can first call
  279.     **    DefaultLayerUpdate to do the CopyBits from the below layer into the middle layer, and then
  280.     **    right after that we can draw the object being dragged into its new location.  The neat thing
  281.     **    about this is that the default behavior can still commonly be used, even if there is extra
  282.     **    stuff that we need to do.
  283.     **
  284.     **    Assuming no errors, we now have a top-most layer relating to the target window, plus a middle
  285.     **    layer for doing the offscreen drawing of the object being dragged.  We now need a background
  286.     **    layer that has an image of the background drawn into it.  This code might look like:
  287.     **
  288.     **        if (!err) err = NewLayer(&backLayer, workLayer, BackLayerProc, nil, 0, (long)&myInfo);
  289.     **
  290.     **    This layer also has its own layer procedure.  The reasoning behind this is that the
  291.     **    initialization would do the drawing into the background.  Once the layers are all set up,
  292.     **    we want the background layer to be fully imaged.  This way there is no time spent for the
  293.     **    background layer, which is the way a background should be.
  294.     **
  295.     **    To recap, the code to create the 3 layers is as follows:
  296.     **
  297.     **                        NewLayer(&windowLayer, nil, nil, window, 0, 0);
  298.     **                  err = NewLayer(&workLayer, windowLayer, WorkLayerProc, nil, 0, (long)&myInfo);
  299.     **        if (!err) err = NewLayer(&backLayer, workLayer, BackLayerProc, nil, 0, (long)&myInfo);
  300.     **
  301.     **    For dragging, we would then have some sort of loop, such as:
  302.     **
  303.     **        Assume the location where the user clicked is already in mouseLoc, local coordinates.
  304.     **
  305.     **        if (err) return;        No ram for the offscreen stuff.
  306.     **
  307.     **        lastLoc.h = lastLoc.v = -32767;        Unclickable initial point.
  308.     **        while (StillDown()) {
  309.     **            if ((lastLoc.h != mouseLoc.h) || (lastLoc.v != mouseLoc.v)) {  Always true first time.
  310.     **                rct.top  = rct.bottom = mouseLoc.v;
  311.     **                rct.left = rct.right  = mouseLoc.h;
  312.     **                rct.bottom += myInfo.objectHeight;
  313.     **                rct.right  += myInfo.objectWidth;
  314.     **                InvalLayer(windowLayer, rct, true);        Update last location, as well as this one.
  315.     **                UpdateLayer(windowLayer);
  316.     **                lastLoc = mouseLoc;
  317.     **            }
  318.     **        }
  319.     **
  320.     **        DisposeThisAndBelowLayers(windowLayer);
  321.     **
  322.     **    As can be seen above, smoothly dragging an object can be very little code.  There are a few
  323.     **    things not handled by the above code, such as if there isn't enough memory for the offscreen
  324.     **    GWorlds.  It isn't really polite to do nothing, as the above code does.  For exception
  325.     **    handling, please see the actual sample code that uses the GWLayers.c package. */
  326.  
  327. void    DetachLayer(LayerObj theLayer);
  328.     /*
  329.     **    ¶ Detach the layer from the layer chain.
  330.     **
  331.     **    INPUT:    theLayer        This is the layer to detach.  If nil is passed in, then
  332.     **                            no action is taken.
  333.     **
  334.     **    Use this call to remove a layer from a layer hierarchy.  This call does
  335.     **    not dispose of the layer. */
  336.  
  337. OSErr    DisposeLayer(LayerObj theLayer);
  338.     /*
  339.     **    ¶ Detach the layer from the layer chain, and then dispose it.
  340.     **
  341.     **    INPUT:    theLayer        This is the layer to detach/dispose.  If nil is passed in,
  342.     **                            then no action is taken.
  343.     **
  344.     **    Dispose of the layer.  If the layer belongs to a hierarchy, it is first
  345.     **    removed from that hierarchy. */
  346.  
  347. OSErr    DisposeThisAndBelowLayers(LayerObj theLayer);
  348.     /*
  349.     **    ¶ Dispose the layer and all layers below it from the layer chain.
  350.     **
  351.     **    INPUT:    theLayer        This is the top layer to detach/dispose.  If nil is passed in,
  352.     **                            then no action is taken.
  353.     **
  354.     **    Dispose of the layer and all layers below it in the hierarchy. */
  355.  
  356. short    GetLayerPosition(LayerObj theLayer);
  357.     /*
  358.     **    ¶ Return the layer position in the hierarchy.
  359.     **
  360.     **    INPUT:    theLayer    This is the layer to determine position for.  If nil is passed in,
  361.     **                        then no action is taken.
  362.     **
  363.     **    Return the layer position in the hierarchy.  0 is the top layer. */
  364.  
  365. LayerObj    GetTopLayer(LayerObj theLayer);
  366.     /*
  367.     **    ¶ Return the top layer in the hierarchy.
  368.     **
  369.     **    INPUT:    theLayer    This is the layer somewhere in the chain.  If nil is passed in,
  370.     **                        then no action is taken.
  371.     **
  372.     **    Return the top layer in the hierarchy. */
  373.  
  374. LayerObj    GetBottomLayer(LayerObj theLayer);
  375.     /*
  376.     **    ¶ Return the bottom layer in the hierarchy.
  377.     **
  378.     **    INPUT:    theLayer    This is the layer somewhere in the chain.  If nil is passed in,
  379.     **                        then no action is taken.
  380.     **
  381.     **    Return the bottom layer in the hierarchy. */
  382.  
  383. void    InsertLayer(LayerObj theLayer, LayerObj referenceLayer, short pos);
  384.     /*
  385.     **    ¶ Insert a layer into a hierarchy.
  386.     **
  387.     **    INPUT:    theLayer        This is the layer to add to the chain.
  388.     **            referenceLayer    This is any layer in the hierarchy theLayer is being added to.
  389.     **            pos                This is the position in the hierarchy that theLayer is being
  390.     **                            added as.
  391.     **
  392.     **    Insert a layer into a hierarchy.  Passing a 0 for position makes the layer the top layer. */
  393.  
  394. OSErr    UpdateLayer(LayerObj theLayer);
  395.     /*
  396.     **    ¶ Return the bottom layer in the hierarchy.
  397.     **
  398.     **    INPUT:    theLayer    This is the layer to update.  If nil is passed in,
  399.     **                        then no action is taken.
  400.     **
  401.     **    Given that a layer update has been posted, do the update.  LayerUpdate does
  402.     **    a recursive update from theLayer down.  If there is a layer below, it calls
  403.     **    LayerUpdate for that layer.  Once the bottom of the hierarchy is reached,
  404.     **    the layerProc is called to do the update.  This causes the layer updates to
  405.     **    occur from bottom up. */
  406.  
  407. Rect    GetEffectiveSrcRect(LayerObj theLayer);
  408.     /*
  409.     **    ¶ Get the effective (logical) source rect for the layer.
  410.     **
  411.     **    INPUT:    theLayer    This is the layer to get the source rect for.  If nil is passed in,
  412.     **                        then no action is taken.
  413.     **
  414.     **    The effectiveSrcRect is srcRect or portRect of the layer.  If there is no srcRect,
  415.     **    (srcRect is empty), then effectiveSrcRect is the layer's portRect. */
  416.  
  417. Rect    GetEffectiveDstRect(LayerObj theLayer);
  418.     /*
  419.     **    ¶ Get the effective (logical) destination rect for the layer.
  420.     **
  421.     **    INPUT:    theLayer    This is the layer to get the destination rect for.  If nil is passed in,
  422.     **                        then no action is taken.
  423.     **
  424.     **    The effectiveDstRect is dstRect or portRect of the layer.  If there is no dstRect,
  425.     **    (dstRect is empty), then effectiveDstRect is the layer's portRect. */
  426.  
  427. OSErr    DefaultLayerProc(LayerObj theLayer, short message);
  428.     /*
  429.     **    ¶ Get the effective (logical) destination rect for the layer.
  430.     **
  431.     **    INPUT:    theLayer    This is the layer to take action on.  If nil is passed in,
  432.     **                        then no action is taken.
  433.     **
  434.     **    The three currently defined message definitions are:
  435.     **
  436.     **    kLayerInit:        Called by NewLayer.  If layerPort is nil (which was
  437.     **                    initialized by NewLayer), then the size/depth of the GWorld
  438.     **                    that is created is dependent on aboveLayer.  If there is no
  439.     **                    aboveLayer, this is an error, and paramErr is returned.
  440.     **                    If the GWorld is successfully created, then layerOwnsPort is
  441.     **                    set true.
  442.     **    kLayerDispose:    Called when a layer is disposed of by either DisposeLayer or
  443.     **                    DisposeThisAndBelowLayers.  It disposes of the GWorld if the
  444.     **                    GWorld is owned by the layer.
  445.     **    kLayerUpdate:   If there is a below layer, kLayerUpdate does a CopyBits from the
  446.     **                    below layer into the current layer.  The copy is done from the
  447.     **                    below layer's effectiveSrcRect into the current layer's
  448.     **                    effectiveDstRect.  The transfer mode used is in xferMode, which
  449.     **                    by default is srcCopy. */
  450.  
  451. Rect    UpdateUpdateRects(LayerObj theLayer);
  452.     /*
  453.     **    ¶ The rect to be updated, plus lastUpdate/thisUpdate management.
  454.     **
  455.     **    INPUT:    theLayer    If nil is passed in, then no action is taken.
  456.     **
  457.     **    Return the rect that is to be updated, plus manage lastUpdate/thisUpdate
  458.     **    so that they apply to the next update. */
  459.  
  460. void    InvalLayer(LayerObj theLayer, Rect invalRect, Boolean includeLastUpdate);
  461.     /*
  462.     **    ¶ Invalidate a rectangle-worth of the layer.
  463.     **
  464.     **    INPUT:    theLayer            The layer to invalidate.  If nil is passed in, then no
  465.     **                                action is taken.
  466.     **            invalRect            The area to invalidate.
  467.     **            includeLastUpdate    If true, then union passed-in rect with last rect, thus
  468.     **                                giving a resulting inval area large enough to enclose the
  469.     **                                last position of an object being dragged.
  470.     **
  471.     **    Post a layer update rect.  The rect is unioned into the thisUpdate for the
  472.     **    layer and all layers below this layer.  If includeLastUpdate is true, then
  473.     **    the field includeLastUpdate is set true for each layer, as well.  This boolean
  474.     **    is used by the default update behavior to determine if the area last updated
  475.     **    should be updated again.  This makes animation effects easier in the the old
  476.     **    and new position for a player being moved are updated at the same time.  This
  477.     **    could be handled by hand by calculating the rect to be updated to include the
  478.     **    last position, but by passing includeLastUpdate as true, it is
  479.     **    handled automatically. */
  480.  
  481. void    SetLayerWorld(LayerObj theLayer);
  482.     /*
  483.     **    ¶ Set the port (and possibly GDevice) to the layer’s.
  484.     **
  485.     **    INPUT:    theLayer        If nil is passed in, then no action is taken.
  486.     **
  487.     **    This is a convenient call for setting a GWorld, while remembering what
  488.     **    the previous GWorld was.  This should be balanced with a call to
  489.     **    ResetLayerWorld.  A count of how many times this is called is kept
  490.     **    so that the old GWorld is cached only if SetLayerWorld is currently
  491.     **    in balance with ResetLayerWorld.  This keeps the oldest kept GWorld
  492.     **    from being overwritten by subsequent calls. */
  493.  
  494. void    ResetLayerWorld(LayerObj theLayer);
  495.     /*
  496.     **    ¶ Reset the port (and possibly GDevice) to before the SetLayerWorld call.
  497.     **
  498.     **    INPUT:    theLayer        If nil is passed in, then no action is taken.
  499.     **
  500.     **    This is used to undo a call to SetLayerWorld.  Calls to ResetLayerWorld
  501.     **    should be balanced with previous calls to SetLayerWorld. */
  502.  
  503. void    LockLayerWorld(LayerObj theLayer);
  504.     /*
  505.     **    ¶ Lock down the pixels for a layer's GWorld.
  506.     **
  507.     **    INPUT:    theLayer        If nil is passed in, then no action is taken.
  508.     **
  509.     **    This is a convenient way to lock down the pixels for a layer's GWorld.
  510.     **    A locked count is kept to make sure that the GWorld is locked only the
  511.     **    first time this is called.  Calls to LockLayerWorld will most likely
  512.     **    be balanced by calls to UnlockLayerWorld, but not necessarily.  It may
  513.     **    be desirable to keep a GWorld layer locked.  In this case, right after
  514.     **    creating the layer (and indirectly its GWorld), call LockLayerWorld.
  515.     **    This will initially lock it.  Subsequent calls would be balanced, and
  516.     **    therefore there will always be one more LockLayerWorld call than
  517.     **    UnlockLayerWorld calls.  This will keep it locked. */
  518.  
  519. void    UnlockLayerWorld(LayerObj theLayer);
  520.     /*
  521.     **    ¶ Unlock down the pixels for a layer's GWorld.
  522.     **
  523.     **    INPUT:    theLayer        If nil is passed in, then no action is taken.
  524.     **
  525.     **    This undoes what LockLayerWorld does.  Calls to UnlockLayerWorld will
  526.     **    generally be balanced with calls to LockLayerWorld. */
  527.  
  528. RgnHandle    ScreenDepthRegion(short depth);
  529.     /*
  530.     **    ¶ Returns region describing area of various screens of at least designated depth.
  531.     **
  532.     **    INPUT:    depth            Minimum screen depth necessary to add monitor to region.
  533.     **
  534.     **    This returns a region describing the area of the various screens that is at least as deep
  535.     **    as the value passed in.  So, if you want to find out what area of the screens has at least
  536.     **    an 8-pixel depth, pass in an 8, and the region returned will describe that area.  If you
  537.     **    want the screen area that is exactly 8 pixels deep, call this function with an 8, and then
  538.     **    call it again with a 9.  Diff out the region returned when 9 was passed in.  The remaining
  539.     **    area is the area that is exactly 8 pixels deep.  (Dispose of both regions when you are done
  540.     **    with them.) */
  541.  
  542. CIconHandle    ReadCIcon(short iconID);
  543.     /*
  544.     **    ¶ System 6&7-savvy GetCIcon call.
  545.     **
  546.     **    INPUT:    iconID            Resource ID of 'cicn' to get.
  547.     **
  548.     **    This function is for system 6/7 compatibility.  System 6 doesn't normally have color icon
  549.     **    support, and if you call the 'cicn' functions in system 6, you will get an unimplemented
  550.     **    trap error.  ReadCIcon calls the color QuickDraw trap GetCIcon if it is available, or it
  551.     **    simply calls GetResource/ReleaseResource if the trap isn't available.
  552.     **
  553.     **    __________
  554.     **
  555.     **    Also see:    DrawCIcon, DrawCIconNoMask, DrawCIconByDepth, KillCIcon. */
  556.  
  557. void        KillCIcon(CIconHandle icon);
  558.     /*
  559.     **    ¶ System 6&7-savvy DisposeCIcon call.
  560.     **
  561.     **    INPUT:    iconID            Resource ID of 'cicn' to dispose.
  562.     **
  563.     **    This call disposes of a 'cicn' handle gotten by calling ReadCicon.
  564.     **
  565.     **    __________
  566.     **
  567.     **    Also see:    DrawCIcon, DrawCIconNoMask, DrawCIconByDepth, ReadCIcon. */
  568.  
  569. void        DrawCIcon(CIconHandle icon, Rect destRect);
  570.     /*
  571.     **    ¶ System 6&7-savvy PlotCIcon call.
  572.     **
  573.     **    INPUT:    iconID            Resource ID of 'cicn' to plot.
  574.     **
  575.     **    This function calls PlotCIcon if it is available, or it dereferences the 1-bit deep bitmap
  576.     **    of the 'cicn' and does a CopyBits if it isn't.
  577.     **
  578.     **    __________
  579.     **
  580.     **    Also see:    DrawCIconNoMask, DrawCIconByDepth, KillCIcon, ReadCIcon. */
  581.  
  582. void        DrawCIconNoMask(CIconHandle icon, Rect destRect);
  583.     /*
  584.     **    ¶ System 6&7-savvy alternate PlotCIcon call.
  585.     **
  586.     **    INPUT:    iconID            Resource ID of 'cicn' to plot with no mask.
  587.     **            destRect        Location to plot 'cicn'.
  588.     **
  589.     **    This function calls PlotCIcon with a temporary mask of nothing masked if it is available,
  590.     **    or it dereferences the 1-bit deep bitmap of the 'cicn' and does a CopyMask if it isn't.
  591.     **
  592.     **    __________
  593.     **
  594.     **    Also see:    DrawCIcon, DrawCIconByDepth, KillCIcon, ReadCIcon. */
  595.  
  596. void        DrawCIconByDepth(CIconHandle icon, Rect destRect, short depth, Boolean useMask);
  597.     /*
  598.     **    ¶ System 6&7-savvy smart PlotCIcon call.
  599.     **
  600.     **    INPUT:    iconID            Resource ID of 'cicn' to plot by depth.
  601.     **            destRect        Location to plot 'cicn'.
  602.     **            depth            Depth to plot 'cicn'.
  603.     **            useMask            True is 'cicn' should be drawn with its mask.
  604.     **
  605.     **    This call does either a CopyBits or CopyMask of the correct part of the 'cicn' resource.
  606.     **    The correct part is determined by the depth.  If a specific depth of 1 is requested, then
  607.     **    the bitmap portion of the 'cicn' is plotted.  If a specific depth of greater than 1 is
  608.     **    requested, and the depth of the target is greater than 1, then the pixmap portion of the 
  609.     **    'cicn' is plotted.
  610.     **
  611.     **    __________
  612.     **
  613.     **    Also see:    DrawCIcon, DrawCIconNoMask, KillCIcon, ReadCIcon. */
  614.  
  615.  
  616.  
  617. #ifdef __cplusplus
  618. }
  619. #endif
  620.  
  621.  
  622.  
  623. #endif
  624.